// pages/houniao/houniao.js
const http = require("../../utils/http");

Page({
  /**
   * 页面的初始数据
   */
  data: {
    indicatorDots: true,//轮播是否有小圆点
    indicatorColor: "white",//false横向  true纵向
    vertical: false,//动画时间
    autoplay: true,//自动播放
    circular: true,//间隔时间
    interval: 2000,//衔接动画
    duration: 500,//衔接时间
    previousMargin: "35rpx",
    nextMargin: "10px",
    swiperList: [],
    list: [],
    recruitList: [],
    guessList: [],

    current: 1,
    show: ["info", "", ""]
  },
  //
  //跳转内容页并传参
  goItem(e){
    console.log(e);
    const id = e.currentTarget.dataset.index;
    wx.navigateTo({
      url:'/pages/item/item?id='+id,
    })
  },
  //招募活动轮播图
  bindchange(e) {
    // console.log(e.detail.current)
    this.setData({
      current: e.detail.current + 1
    });
    let list = ["", "", ""];
    list[e.detail.current] = "info";
    this.setData({
      show: list
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //top轮播图
    http.request("product/banner/getBySeller/4bc4027c645343f09a964b5c2e9f875b", "", "get").then(res => {
      console.log(res);
      this.setData({
        swiperList: res.data
      });
    });
    //推荐
    http.request("product/product/getProductRecommendUser", {
      desc: false,
      orderBy: "top",
      pageNow: 1,
      pageSize: 20,
      seller_user_id: "4bc4027c645343f09a964b5c2e9f875b"
    }, "post").then(res => {
      console.log(res);
      this.setData({
        list: res.data
      });
    });
    //招募活动
    http.request("requirement/request/getMatchedProducts", {
      desc: false,
      orderBy: "outtime",
      pageSize: 100,
      product_type: 2
    }, "post").then(res => {
      console.log(res.data.matchedProducts);
      this.setData({
        recruitList: res.data.matchedProducts
      })
    });
    //猜你喜欢
    http.request("product/product/guessYouLike", "", "get").then(res => {
      console.log(res.data);
      this.setData({
        guessList: res.data
      })
    });
  },

  /**
   * 生命周期函数--监听页面显示,//进入时开启轮播图
     */
  onShow: function () {
    this.setData({autoplay:true});
  },

  /**
   * 生命周期函数--监听页面隐藏,//停止轮播图
     */
  onHide: function () {
    this.setData({autoplay:false});
  },

  /**

   * 生命周期函数--监听页面卸载
     */
  onUnload: function () {

  },

  /**

   * 页面相关事件处理函数--监听用户下拉动作
     */
  onPullDownRefresh: function () {

  },

  /**

   * 页面上拉触底事件的处理函数
     */
  onReachBottom: function () {

  },

  /**

   * 用户点击右上角分享
     */
  onShareAppMessage: function () {

  }
})